<!--
 * @Author: caojia
 * @Date: 2023-11-07 11:45:09
 * @LastEditTime: 2023-11-07 12:19:11
 * @LastEditors: caojia
 * @Description: file content
 * @FilePath: \vue2-webfront\src\views\HomeView.vue
 * 可以输入预定的版权声明、个性签名、空行等
-->
<template>
    <Form
        ref="formInline"
        :model="formInline"
        :rules="ruleInline"
        inline
    >
        <FormItem prop="user">
            <Input
                v-model="formInline.user"
                type="text"
                placeholder="Username"
            >
                <Icon
                    slot="prepend"
                    type="ios-person-outline"
                />
            </Input>
        </FormItem>
        <FormItem prop="password">
            <Input
                v-model="formInline.password"
                type="password"
                placeholder="Password"
            >
                <Icon
                    slot="prepend"
                    type="ios-lock-outline"
                />
            </Input>
        </FormItem>
        <FormItem>
            <Button
                type="primary"
                @click="handleSubmit('formInline')"
            >
                Signin
            </Button>
        </FormItem>
    </Form>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'

export default {
    name: 'HomeView',
    data () {
        return {
            formInline: {
                user: '',
                password: ''
            },
            ruleInline: {
                user: [
                    { required: true, message: 'Please fill in the user name', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: 'Please fill in the password.', trigger: 'blur' },
                    { type: 'string', min: 6, message: 'The password length cannot be less than 6 bits', trigger: 'blur' }
                ]
            }
        };
    },
    methods: {
        handleSubmit (name) {
            this.$refs[name].validate((valid) => {
                if (valid) {
                    this.$Message.success('Success!');
                } else {
                    this.$Message.error('Fail!');
                }
            });
        }
    }
};
</script>
